package current.limiting.controller;

import current.limiting.annotions.Limiting;
import current.limiting.commom.enumerate.LimitType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * 接口限流相关网络接口
 *
 * @author LiKun
 * @date 2021/10/25 10:58
 */
@RestController
@RequestMapping("/limit")
public class CurrentLimitController {
    public static final String PREFIX = "输入数据为：";

    @GetMapping("/display/{value}")
    @Limiting(value = "display", limitTime = 5, blockTime = 3, accessQuantity = 5, timeUnit = TimeUnit.SECONDS, limitType = LimitType.IP)
    public String displayValue(@PathVariable String value) {
        return (PREFIX + value).intern();
    }
}
